package cn.enine.autocopy.pojo;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.io.Serializable;
import java.lang.reflect.Field;

import cn.enine.autocopy.R;

/**
 * Created by Administrator on 2017/12/9.
 */

public class Person implements Serializable {
    private String id;
    private String name;
    private String phone;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }

    public void init(Object obj, Activity temp, View layout){
        try {
            Class clazz = obj.getClass();
            //获得对象的所有成员变量
            Field[] fields = clazz.getDeclaredFields();
            for(Field field : fields) {
                //获取成员变量的名字
                String name = field.getName();
                //View view = (View) layout.findViewById(vieId);
            }




            Field idFid = clazz.getDeclaredField("name");
            idFid.setAccessible(true);
            //LinearLayout linearLayout = (LinearLayout) idFid.get(temp);

            Field bFid = clazz.getDeclaredField("phone");
            bFid.setAccessible(true);
            View view = (View) layout.findViewById(R.id.name);
            if(view instanceof Button){

            }else if(view instanceof TextView){
                TextView textView = (TextView)view;
                System.out.println("====>"+textView.getText());
            }else if(view instanceof EditText){
                EditText editText = (EditText)view;
                System.out.println(editText.getText());
            }

        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }

    }
}
